package com.example.redisrabbitesintegeation.model.document;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @ClassName News
 * @Description 新闻文档
 * @Author Kx
 * @Date 2025/10/21 16:27
 * @Version 1.0
 */
@Document(indexName = "news", createIndex = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class News {
    @Id
    private Integer newsId; // 新闻id
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title; // 新闻标题
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String author; // 新闻作者
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String classify; // 新闻分类
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String text; // 新闻内容
    @Field(type = FieldType.Date, index = false, format = DateFormat.date_time, pattern = "yyyy-MM-dd")
    private Date createdTime; // 发布日期
}
